package com.xjrsoft.module.language.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.language.entity.XjrLgMark;
import com.xjrsoft.module.language.mapper.XjrLgMarkMapper;
import com.xjrsoft.module.language.service.IXjrLgMarkService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zwq
 * @since 2021-08-31
 */
@Service
public class XjrLgMarkServiceImpl extends ServiceImpl<XjrLgMarkMapper, XjrLgMark> implements IXjrLgMarkService {

    @Override
    public XjrLgMark getLgMarkByCode(String enCode) {
        if (StringUtil.isEmpty(enCode)) {
            return null;
        }
        return this.getOne(Wrappers.<XjrLgMark>query().lambda().eq(XjrLgMark::getEnCode, enCode), false);
    }

    @Override
    public boolean isUnique(String id, String code) {
        return this.count(Wrappers.<XjrLgMark>query().lambda().eq(XjrLgMark::getEnCode, code).ne(!StringUtil.isEmpty(id), XjrLgMark::getId, id)) < 1;
    }
}
